package dw.database;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

 

public class JdbcStatement {
  
	private Connection con;

	public JdbcStatement(Connection con) {
		this.con = con;
	}

	public void executeQuery(String stmt, ResultMapper mapper) {
		try {
			Statement createStatement = con.createStatement();
			ResultSet executeQuery = createStatement.executeQuery(stmt);
			mapper.mapResults(executeQuery);
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

	public int executeUpdate(String stmt) {
		Statement createStatement;
		try {
			createStatement = con.createStatement();
			int executeUpdate = createStatement.executeUpdate(stmt);
			createStatement.close();

			return executeUpdate;
		} catch (SQLException e) {
		 
			throw new RuntimeException(e);
		}
	}

}
